#coding:utf-8
from locust import  TaskSet,task,HttpUser
import  os
import  time
# 定义用户行为
from locust import HttpUser, TaskSet, task
# 定义用户行为类
class UserBehavior(TaskSet):
    def setup(self):
        print("开始...")
    def teardown(self):
        print("结束...")
    @task(1)  # 任务项
    def test_login(self):
        user_info = {
            'username': '****',
            'password': '*****'
        }
        url = r'https://smart.mail.163.com/login.htm'
        res = self.client.get(url, data=user_info)
        if res.status_code == 200:
            print('登陆成功！')
        else:
            print('登陆失败！')

class WebSiteUser(HttpUser):
    host = r'https://smart.mail.163.com/login.htm'
    #task_create = UserBehavior
    tasks = [UserBehavior]
    max_wait = 5000
    min_wait = 1000
if __name__=='__main__':
    cmd = 'locust -f testlocust.py '
    os.system(cmd)